#include <cmath>
#include <fstream>
#include <iostream>
using namespace std;

#include "hmm.h"

int main(int argc, char* argv[])
{
    Hmm hmm;
    hmm.loadProbs(argv[1]);
    string line;
    while( getline(cin,line) )
    {
        vector<unsigned int> seq;
        while( line.size() )
        {
            string word;
            string::size_type spaceidx = line.find(" ");
            if( spaceidx != string::npos )
            {
                word = line.substr(0, spaceidx);
                line = line.substr(spaceidx + 1, line.size() - spaceidx - 1);
            }
            else
            {
                word = line;
                line = "";
            }
            seq.push_back(hmm.getId(word));
        }
        line.clear();
        vector<unsigned int> path;
        hmm.viterbi2(path, seq);
        for (unsigned int i = 0; i<path.size(); i++) 
        {
                cout << hmm.getStr(seq[i]) << '/' << hmm.getStr(path[i]) << " ";
        }
        cout<<endl;
        //hmm.reset();
    }
}
